<template>
  <div :class="modell">
    <van-nav-bar left-arrow @click-left="onClickLeft" />
    <div class="My-content">
      <div class="user-info">
        <img
          class="user-avatar"
          src="https://pic2.zhimg.com/84aa03ad32d328354dc96485a1637f67_l.jpg?source=8673f162"
          alt
        />
        <div class="user-name">kevinkim</div>
      </div>
      <div>
        <van-cell @click="goCollection" title="收藏" is-link />
        <van-cell title="设置" is-link />
      </div>

      <div :class="type" @click="dackModell">{{type=='theme-dark'?'夜间模式':'日间模式'}}</div>
      <div class="signout" @click="signout">退出登录</div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      modell: "",
      flag: true,
      type: "theme-dark"
    };
  },
  methods: {
    onClickLeft() {
      this.$router.push({
        name: "index"
      });
    },
    dackModell() {
      if (localStorage.getItem("modell")) {
        localStorage.removeItem("modell");
        this.flag = false;
      } else {
        localStorage.setItem("modell", "dark");
        this.flag = true;
      }
      this.$router.go(0);
    },
    signout() {
      localStorage.removeItem("isLogin");
      this.$router.go(0);
    },
    goCollection() {
      this.$router.push({
        name: "Collection"
      });
    }
  },
  created() {
    if (localStorage.getItem("modell")) {
      this.type = "theme-sun";
    }
    this.modell = localStorage.getItem("modell");
  }
};
</script>
<style lang="less" scoped>
/deep/.van-nav-bar .van-icon {
  color: #000;
}
/deep/.van-nav-bar__arrow {
  font-size: 25px;
}
.My-content {
  .user-info {
    margin-top: 20px;
    text-align: center;
    .user-avatar {
      border-radius: 50%;
      overflow: hidden;
      width: 80px;
      height: 80px;
    }
    .user-name {
      margin-top: 10px;
      font-size: 18px;
      color: #000;
      margin-bottom: 30px;
    }
  }
}
.dark {
  height: 100vh;
  color: rgb(241, 232, 232);
  background: #000;

  /deep/.van-nav-bar__content {
    background: #000;
  }

  /deep/.van-nav-bar .van-icon {
    color: rgb(98, 97, 97) !important;
  }
  /deep/.van-nav-bar__arrow {
    font-size: 25px;
  }
  .My-content {
    .user-name {
      font-size: 18px;
      color: rgb(98, 97, 97);
    }
  }
  .signout {
    position: absolute;
    bottom: 50px;
    right: 70px;
    width: 50px;
    height: 50px;
    background: url("../assets/jieshu.png") no-repeat center;
    background-size: 70%;
    line-height: 120px;
  }
  .van-cell {
    color: rgb(221, 216, 216);
    background: #000;
  }
}
.theme-dark {
  position: absolute;
  bottom: 50px;
  left: 70px;
  width: 50px;
  height: 50px;
  background: url("../assets/yueduye-yejianmoshi.png") no-repeat center;
  background-size: 70%;
  line-height: 120px;
}
.theme-sun {
  position: absolute;
  bottom: 50px;
  left: 70px;
  width: 50px;
  height: 50px;
  background: url("../assets/rijianmoshixhdpi.png") no-repeat center;
  background-size: 70%;
  line-height: 120px;
}
.signout {
  position: absolute;
  bottom: 50px;
  right: 70px;
  width: 50px;
  height: 50px;
  background: url("../assets/jieshu_s.png") no-repeat center;
  background-size: 70%;
  line-height: 120px;
}
</style>